package hyo.hun.lifemanager.today;

import hyo.hun.lifemanager.R;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class TodayListAdapter extends ArrayAdapter {

	private Context context;
	private int textViewResourceId;
	private ArrayList<TodayData> list;
	
	public TodayListAdapter(Context context, int textViewResourceId, ArrayList<TodayData> list) {
		super(context, textViewResourceId, list);
		
		this.context = context;
		this.textViewResourceId = textViewResourceId;
		this.list = list;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		View v = convertView;
		
		if (v == null)
		{
			LayoutInflater li = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
			v = li.inflate(R.layout.today_activity_list_item, null);
		}
		
		TodayData data = list.get(position);
		
		TextView title = (TextView) v.findViewById(R.id.list_item_today_title);
		TextView text = (TextView) v.findViewById(R.id.list_item_today_text);
		
		title.setText(data.getId());
		text.setText(data.getText());
		
		return v;
	}

}
